<template>
  <div id="welcome">  
   
   <div  style="display:flex;align-items: center;">
            <img class="top_img" src="@/assets/images/a8.png" style="width:35px;height:35px;margin-right:10px;"/>
            <div style="line-height: 40px;font-weight:bold:">蜜贝迎新礼</div>
    </div> 

  <el-form ref="form"  label-width="70px">  

     <div style="display:flex;">
          <div style="flex:1;display:flex;align-items: center;">

          <div style="width:50px;text-align-last: justify;margin-top:-12px;font-size: 14px;color: #606266;margin-right:10px;">查询项</div>
            <el-form-item label="账户查询">
              <el-input v-model="form.phone" placeholder="姓名/手机号"  style="width:140px;"></el-input>
            </el-form-item>

            <div class="buttoon_box">
                <div class="buttoon_box_item"  style="margin-left:10px;background:#FFC600;color:white;" @click="search_but1()">确 定</div>
                <div class="buttoon_box_item" style="margin-left:10px;border:1px solid #D9D9D9;" @click="sx_but()">清 空</div>    
            </div>

         </div>

     </div>

     <div style="display:flex;align-items: center;">
            <div style="width:50px;text-align-last: justify;margin-top:-12px;font-size: 14px;color: #606266;margin-right:10px;">筛选项</div> 

            <el-form-item  label="选择日期"  >
                    <el-date-picker  type="date"   placeholder="选择日期" format="yyyy-MM-dd" value-format="yyyy-MM-dd"  v-model="form.onedate" style="width:140px;"> 
                    </el-date-picker>
              </el-form-item>
            
            <el-form-item label="订单状态" style="margin-left:10px;">
                <el-select  v-model="form.select_num" placeholder="请选择" >
                    <el-option  v-for="(item,index) in select_data" :key="index" :label="item.name" :value="item.id"></el-option>
                </el-select>
            </el-form-item>
 
            <div class="buttoon_box">
                <div class="buttoon_box_item"  style="margin-left:10px;background:#FFC600;color:white;" @click="search_but2()">确 定</div>
                <div class="buttoon_box_item" style="margin-left:10px;border:1px solid #D9D9D9;" @click="sx_but()">清 空</div>    
            </div>
     </div>

     <el-col :span="24" style="text-align: right;">          
         <el-button type="primary" class="custom_color_button1" style="margin-bottom:10px;" @click="mtk2_but()">
           <img class="custom_color_button1_img" src="@/assets/images/but_bg6.png" />兑换设置
          </el-button>
         <el-button type="primary" class="custom_color_button1" style="margin-bottom:10px;" @click="mtk1_but()">
           <img class="custom_color_button1_img" src="@/assets/images/but_bg6.png" />获奖要求
          </el-button>
         <el-button type="primary" class="custom_color_button1" style="margin-bottom:10px;" @click="go_participate_but()">
           <img class="custom_color_button1_img" src="@/assets/images/but_bg6.png" />参与人数
          </el-button>     
      </el-col>

  </el-form >

   <!-- 渲染数据list -->
   <welcome-list :guomidata="guomidata" @up_list_fun="list_fun"> </welcome-list>

      
   <div style="margin-top:20px;text-align: center;">
      <el-pagination
        background
        @current-change="handleCurrentChange"
        :page-size="10"  
        layout="prev, pager, next, jumper"
        :total="count">
      </el-pagination>
    </div>

     <!-- 获奖要求 -->
    <el-dialog title="获奖要求" :visible.sync="mtk1"  width="400px">
        <div style="width:100%;"> 

            <el-form ref="form"   label-width="70px" style="width:100%;">     
                <el-form-item label="新人天数">
                    <el-input    v-model="mtk1_form.novice_kmb_gobuy_can_days" placeholder="新人天数"></el-input>
                </el-form-item>
                <!-- <el-form-item label="次数">
                    <el-input    v-model="mtk1_form.novice_kmb_gobuy_can_number" readonly="readonly" placeholder="次数"></el-input>
                </el-form-item> -->

           </el-form>
            <div style="text-align: center;width:50%;margin:auto;">
                <el-button type="primary" class="custom_color_button" style="width:80%;" @click="mtk1_qr_but()">确认</el-button>
            </div>

        </div> 
    </el-dialog>

     <!-- 兑换设置 -->
    <el-dialog title="兑换设置" :visible.sync="mtk2"  width="580px">
        <div style="width:100%;"> 
                
                <el-form ref="form"  label-width="70px">  
                <el-row>  
                     <el-col :span="24">  
                           <div style="height:50px;background: #4F81BC;display:flex;line-height:50px;">
                               <div style="flex:1;color:white;padding-left:10px;border-right:1px solid white;">兑换数</div>
                               <div style="flex:1;color:white;padding-left:10px;">奖励数</div>
                           </div>
                     </el-col>                                              
                    <el-col :span="24" style="display:flex;margin-top:10px;" v-for="(item,index) in mtk2_form.datalist" :key="index">
                        <el-form-item :label="'兑换数' + (index+1)" label-width="" style="margin-bottom: 0px !important;flex:;1">
                                <el-input style="width:200px;" v-model="item.kmb_number" placeholder=""></el-input>
                         </el-form-item> 
                         <el-form-item :label="'奖励数' + (index+1)" label-width="" style="margin-bottom: 0px !important;flex:;1">
                                <el-input style="width:200px;"  v-model="item.give_kmb_number" placeholder=""></el-input>
                         </el-form-item>   
                    </el-col>
                </el-row>
       
             
          </el-form>
                
                <div style="text-align: center;width:50%;margin:auto;margin-top:30px;">
                        <el-button type="primary" class="custom_color_button" style="width:150px;border-radius: 50px;" @click="mtk2_but_qr()">确认</el-button>
                </div>
        </div> 
    </el-dialog>


   
      
  </div>
</template>

<script>
import WelcomeList from '@/view/Activitynew/Welcome/WelcomeList'
export default {
  name: 'welcome',
  data () {
    return {
        guomidata:[],
        page:1,
        count:0,
        select_data:[{"id":1,"name":"新订单"},{"id":2,"name":"已驳回"}
        ,{"id":6,"name":"已完成"},{"id":4,"name":"卖家申述"},{"id":3,"name":"新上传"},{"id":5,"name":"买家申述"},{"id":7,"name":"已取消"}],
        form:{
          select_num:1,
          phone:'',
          onedate:''
        },
        mtk1:false,
        mtk1_form:{
          novice_kmb_gobuy_can_days:'',
          novice_kmb_gobuy_can_number:1,
        },

        mtk2:false,
        mtk2_form:{
          datalist:[],
        }
     
    }
  },
 components:{
    WelcomeList
  },
  created(){
      this.list_fun()
      this.set_fun()
  },
  mounted (){
    
  },
  methods: {
     exchange_run(){
        this.post("/novice_kmb/dataOfFirst", {
        }).then(res => { 
              this.mtk2_form.datalist = res.result  
            console.log(res,"dddd")           
        })
     },
     set_fun(){
        this.post("/novice_kmb/limitItem", {
        }).then(res => { 
               this.mtk1_form.novice_kmb_gobuy_can_days = res.result.novice_kmb_gobuy_can_days
               this.mtk1_form.novice_kmb_gobuy_can_number = res.result.novice_kmb_gobuy_can_number
           // console.log(res,"dddd")                  
        })
      },
     list_fun(){
          this.post("/buy_kmb/listData", {
              page:this.page,
              type:this.form.select_num,
              onedate:this.form.onedate,
              account:this.form.phone,
              novice:2,
	        }).then(res => {
            this.count = res.result.count
            this.guomidata = res.result.list

             for(let item of this.guomidata) {

                item.srcList = [this.urlimg + item.voucher_link]
                    
            }

             console.log(res,"aaa")
         })
      },
      mtk1_but(){
         this.mtk1 = true
      },
      mtk1_qr_but(){
         this.post("/novice_kmb/setColorItem", {
                    novice_kmb_gobuy_can_days:this.mtk1_form.novice_kmb_gobuy_can_days,
                    novice_kmb_gobuy_can_number:this.mtk1_form.novice_kmb_gobuy_can_number,
                }).then(res => {

                    if(res.error_code == 0){
                      this.mtk1 = false
                      this.set_fun()
                     this.open1(res.result,'success')  //提示框
                    }else {
                     this.open1(res.message,'warning')
                }

         })
      },
      mtk2_but(){
        this.exchange_run()
        this.mtk2 = true
      },
      mtk2_but_qr(){
          
          this.post("/novice_kmb/setFirstData", {
                   arr:this.mtk2_form.datalist
                }).then(res => {

                    if(res.error_code == 0){
                      this.mtk2 = false
                      this.exchange_run()
                     this.open1(res.result,'success')  //提示框
                    }else {
                     this.open1(res.message,'warning')
                }

         })

      },
      go_participate_but(){
          this.$router.push({
          path: '/index/activitynew/welcome/participate',
          query: {
            
          }
        })
      },
      search_but1(){
         this.page = 1
         this.list_fun()
      },
      search_but2(){
         this.page = 1
         this.list_fun()
      },
      sx_but(){
        this.form={
          select_num:1,
          phone:'',
          onedate:''
        }
         this.page = 1
         this.list_fun()
      },
     handleSizeChange(val) {
        console.log(`每页 ${val} 条`);
      },
      handleCurrentChange(val) {
        this.page = val
        this.list_fun()
        console.log(`当前页: ${val}`);
      }
  }
}
</script>


<style scoped>
.imgarr{
  width: 100px;
  height: 100px;
  margin-left: 10px;
  margin-bottom: 10px;
}
 .avatar-uploader  {
    border: 1px dashed #d9d9d9;
    border-radius: 6px;
    cursor: pointer;
    position: relative;
    overflow: hidden;
  }
  .avatar-uploader-icon {
    font-size: 28px;
    color: #8c939d;
    width: 178px;
    height: 178px;
    line-height: 178px;
    text-align: center;
  }
  .avatar {
    width: 178px;
    height: 178px;
    display: block;
  }
  .mytitle{
    height: 35px;
}
.mytitle_item{
    display: flex;
    align-items: center;
   
}
.mytitle_item::before{
  content:'';
  width: 5px;
  height: 15px;
  background: #F5CF49;
  display: block;
   margin-right: 10px;
}
.tb_class{
    color:#F5CF49;
    font-size:30px;
    margin-top:5px;
    margin-left:15px;
    margin-right:15px;
  }
  .my_input>>>input{
      width: 300px;
  }
  .img{
      width: 40px;
      height: 40px;
      margin-left: 20px;
  }
  .buttoon_box{
  display:flex;margin-bottom:10px;
}
.buttoon_box_item{
  height:40px;line-height:40px;width:60px;font-size:14px;text-align:center;border-radius:5px;
}
.el-input-box>>>input{
  padding: 0px 3px !important;
}
</style>
